package com.registration.controller;

import com.registration.entity.ResultEntity;
import com.registration.entity.YlPatientControl;
import com.registration.server.SickServer;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.utils.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 患者信息调用
 * */
@RestController
@RequestMapping("/sick")
public class SickController {

    @Autowired
    SickServer sickServer;

    @Autowired
    RabbitTemplate rabbitTemplate;

    //添加患者信息
    @RequestMapping("/addSick")
    public ResultEntity addSick(@RequestBody YlPatientControl ylPatientControl){
        int a = sickServer.addSick(ylPatientControl);
        return new ResultEntity<>(200,"添加成功",null);
    }

    //查询当前账户id的所有关联患者信息
    @GetMapping("/findAll/{accountid}")
    public ResultEntity<List<YlPatientControl>> findAll(@PathVariable("accountid")int accountId){
        return new ResultEntity<>(200,"查旬成功",sickServer.findAll(accountId));
    }

    //根据id删除患者信息
    @GetMapping("/deleteSick/{id}")
    public ResultEntity deleteSick(@PathVariable("id")int accountId){
        int a = sickServer.deleteSick(accountId);
        return new ResultEntity<>(200,"删除成功",null);
    }

    //查询当前账户id的所有关联患者信息
    @GetMapping("/findAlla")
    public ResultEntity<List<YlPatientControl>> findAlla(){
        return new ResultEntity<List<YlPatientControl>>(200,"查旬成功",sickServer.findAlla());
    }
}
